package com.ywd.materials.admin.controller;

import com.ywd.materials.admin.dto.MaterialsTeachVideoDto;
import com.ywd.materials.admin.dto.query.MaterialsTeachVideoQuery;
import com.ywd.materials.admin.exception.R;
import com.ywd.materials.admin.exception.RPage;
import com.ywd.materials.admin.service.impl.MaterialsTeachVideoServiceImpl;
import com.ywd.materials.admin.vo.MaterialsTeachVideoVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lk
 * @date 2024/4/17 13:53
 */
@AllArgsConstructor
@RestController
@RequestMapping("/teachVideo")
@Tag(name = "教学视频管理")
public class MaterialsTeachVideoController {

    private final MaterialsTeachVideoServiceImpl materialsTeachVideoServiceImpl;

    @PostMapping("/addTeach")
    @Operation(summary = "添加教学视频")
    public R<Boolean> addTeach(@RequestBody MaterialsTeachVideoDto dto) {
        return R.ok(materialsTeachVideoServiceImpl.addTeach(dto));
    }

    @PutMapping("/updateTeach")
    @Operation(summary = "修改教学视频")
    public R<Boolean> updateTeach(@RequestBody MaterialsTeachVideoDto dto) {
        return R.ok(materialsTeachVideoServiceImpl.updateTeach(dto));
    }

    @DeleteMapping("/deleteTeach")
    @Operation(summary = "删除教学视频")
    public R<Boolean> deleteTeach(@Schema(description = "ID") @RequestParam Long id) {
        return R.ok(materialsTeachVideoServiceImpl.deleteTeach(id));
    }

    @PostMapping("/getTeachPage")
    @Operation(summary = "查询列表(分页)")
    public R<RPage<List<MaterialsTeachVideoVo>>> getTeachPage(@RequestBody MaterialsTeachVideoQuery query) {
        return R.ok(materialsTeachVideoServiceImpl.getTeachPage(query));
    }

}
